package com.nero.fbloginsample;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;

import com.facebook.AccessToken;
import com.facebook.AccessTokenTracker;
import com.facebook.CallbackManager;
import com.facebook.FacebookCallback;
import com.facebook.FacebookException;
import com.facebook.GraphRequest;
import com.facebook.login.LoginManager;
import com.facebook.login.LoginResult;
import com.facebook.login.widget.LoginButton;

import java.util.Arrays;

import de.hdodenhof.circleimageview.CircleImageView;

public class MainActivity extends AppCompatActivity {
    private LoginButton loginbutton;
    private CircleImageView CircleImageView;
    private TextView txtName,txtEmail;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        loginbutton = findViewById(R.id.fb_login_button);
       // txtName = findViewById(R.id.profile_name);
        //txtEmail = findViewById((R.id.profile_email);
        CircleImageView = findViewById(R.id.profile_pic);

        CallbackManager callbackManager = CallbackManager.Factory.create();
        loginbutton.setPermissions(Arrays.asList("email", "public_profile"));


        loginbutton.registerCallback(callbackManager, new FacebookCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {

            }

            @Override
            public void onCancel() {

            }

            @Override
            public void onError(FacebookException error) {

            }
        });
    }
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        CallbackManager callbackManager = null;
        callbackManager.onActivityResult(requestCode, resultCode, data);
        super.onActivityResult(requestCode, resultCode, data);
    }

/*    AccessToken accessToken = AccessToken.getCurrentAccessToken();
    boolean isLoggedIn = accessToken != null && !accessToken.isExpired();
    {
        LoginManager.getInstance().logInWithReadPermissions(this,Arrays.asList("public_profile"));
    }*/
    AccessTokenTracker tokenTracker = new AccessTokenTracker()
    {
    @Override
    protected void onCurrentAccessTokenChanged(AccessToken oldAccessToken, AccessToken currentAccessToken)
    {

    }

    };
    private void loaduserProfile(AccessToken newAccessToken)
    {

        GraphRequest request = GraphRequest.newGraphPathRequest();
    }
}





